<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:80:"D:\phpstudy_pro\WWW\nmg002\public/../application/admin\view\graduates\index.html";i:1673450518;}*/ ?>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> <?php echo $setting['webname']; ?>- 打印毕业证</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="/public/static/favicon.ico">
    <link href="/public/static/admin/layui/css/layui.css" rel="stylesheet">
    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/animate.css" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/footable/footable.core.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/switchery/switchery.css" rel="stylesheet">


</head>

<body class="gray-bg">
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-sm-4">
            <h2>证书管理</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="<?php echo url('Admins/admin'); ?>">主页</a>
                </li>
                <li>
                    <strong>毕业证打印</strong>
                </li>
            </ol>
        </div>
        <div class="col-sm-8" style="text-align: right;line-height: 15px;margin-top:25px;">

        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeIn">
        <div class="row">
            <div class="col-sm-12">
                <form action="" id="form1">
                <div class="row" style="margin-bottom: 20px">
                    <div class="col-sm-2">
                        <input type="text" placeholder="姓名" name="name" id="name" class="input form-control">
                    </div>
                    <div class="col-sm-2">
                        <select name="sex" id="sex" class="form-control">
                            <option value="" readonly selected>性别</option>
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </div>
                    <div class="col-sm-2">
                        <input type="text" placeholder="民族" name="nation" id="nation" class="input form-control">
                    </div>
                    <div class="col-sm-3">
                        <input type="text" placeholder="身份证号" name="idcards" id="idcards" class="input form-control">
                    </div>
                    <div class="col-sm-3">
                        <input type="text" placeholder="通讯地址" name="address" id="address" class="input form-control">
                    </div>
                </div>
                <div class="row" style="margin-bottom: 20px">

                    <div class="col-sm-2">
                        <select name="major" id="major33"  class="form-control">
                            <option value="" readonly selected>专业</option>
                            <?php foreach($course as $v): ?>
                            <option value="<?php echo $v['name']; ?>"><?php echo $v['name']; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                    <div class="col-sm-2">
                        <input type="text" placeholder="毕业证编号" name="advice_note" id="advice_note" class="input form-control">
                    </div>
                    <div class="col-sm-2">
                        <button type="button" class="btn btn btn-info" style="width: 100%" id="search"> <i class="fa fa-search"></i> 搜索</button>
                    </div>
                    <div class="col-sm-2">
                        <button type="button" class="btn btn-success"  style="width: 100%" id="test3"><i class="layui-icon"></i> 上传文件</button>
                    </div>
                    <div class="col-sm-2">
                        <a href="<?php echo url('Graduates/byzExcel'); ?>">
                            <button type="button" class="btn btn btn-success" style="width: 100%" id="excel"> <i class="fa fa-download"></i> 导出Excel</button>
                        </a>
                    </div>
                    <div class="col-sm-2">
                        <button type="button" class="btn btn btn-danger" style="width: 100%" id="delall"> <i class="fa fa-remove"></i> 清空数据</button>
                    </div>
                </div>
                </form>
                <div class="tabs-container">
                    <div class="tab-content">

                        <!--新闻列表开始-->
                            <div class="table-responsive">
                                <table class="footable table table-stripped toggle-arrow-tiny table-hover" data-page-size="15">
                                    <thead>
                                    <tr>
                                        <th data-toggle="true">序号</th>
                                        <th>毕业证编号</th>
                                        <th>姓名</th>
                                        <th>性别</th>
                                        <th>民族</th>
                                        <th>身份证号</th>
                                        <th>家庭住址</th>
                                        <th>专业</th>
                                        <th>打印时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody id="datas">

                                    </tbody>
                                </table>
                            </div>
                        <!-- 列表结束 -->
                        <tfoot>
                        <tr>
                            <td colspan="9">
                                <ul class="pagination pull-left"></ul>
                            </td>
                        </tr>
                        </tfoot>
                    </div>
                </div>
            </div>
        </div>
       
    </div>
    <!--弹出层-->
    <style>
        .layer_notice{
            width: 90%;
            margin:10px auto;
            line-height: 30px;
            display: none;
        }
        .layer_notice select{
            height: 35px;
        }
    </style>
    <!--第一页-->
    <div class="layer_notice" id="print_first" style="width: 396px;height:561px">

    </div>
    <!--弹出层-->
    <!-- 全局js -->
    <script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>

    <script src="/public/static/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- iCheck -->
    <script src="/public/static/admin/js/plugins/iCheck/icheck.min.js"></script>
    <!-- Switchery -->
    <script src="/public/static/admin/js/plugins/switchery/switchery.js"></script>

    <!-- 自定义js -->
    <script src="/public/static/admin/js/content.js?v=1.0.0"></script>
    <script src="/public/static/admin/layui/layui.js"></script>
    <script src="/public/static/admin/js/plugins/footable/footable.all.min.js"></script>
    <script src="/public/static/admin/js/jquery.jqprint-0.3.js"></script>
    <script>
        $(document).ready(function() {
            $('.footable').footable();
            $(".tabs").attr("class","tab-pane");
        });
        layui.use(['upload', 'element', 'layer'], function(){
            var $ = layui.jquery
                    ,upload = layui.upload
                    ,element = layui.element
                    ,layer = layui.layer;

            //查询内容
            $("#search").on("click",function(){
                 var form = $("#form1").serializeArray()
                 var data = {}
                 form.forEach((_this)=>{
                     data[_this.name] = _this.value;
                })
                console.log(data);
                $.post("<?php echo url('Graduates/toSearch'); ?>", data ,function(data){
                    if(data.code){
                        $("#datas").html(data.msg).trigger('footable_redraw');
                    }else{
                        top.layer.closeAll();
                        top.layer.msg(data.msg,{time:2000,shade:0.5},function(){
                            if(data.url){
                                window.location.href = data.url;
                            }
                        });
                    }
                });
            });
            $("#search").click();
            //打印第一页
            $("#datas").on("click",'.print_first',function(){
                //请求数据，生成图片
                var content = $("#print_first")
                var _this = $(this)
                content.empty();

                var base64="";
                var img = new Image();
                img.src= "<?php echo url('Graduates/first_page'); ?>?id="+_this.data('id');
                img.onload=function(){
                    base64 = image2Base64(img);
                    content.append($("<img src='"+base64+"' width='100%'/>")); //装转为Base64的图片添加到窗口中
                }
                //页面层
                layer.open({
                    type: 1,
                    skin: false, //加上边框
                    title: "毕业证第一页",
                    area: ['400px', 'AUTO'], //宽高
                    content: content,  //
                    btn:['打印',"取消"],
                    yes:function(){
                        content.jqprint();
                        layer.load(1, {
                            shade: 0.5,
                            time: 3*1000,
                        });
                    }
                });
            });
            //打印第二页
            $("#datas").on("click",'.print_two',function(){
                //请求数据，生成图片
                var content = $("#print_first")
                var _this = $(this)
                content.empty();

                var base64="";
                var img = new Image();
                img.src= "<?php echo url('Graduates/two_page'); ?>?id="+_this.data('id');
                img.onload=function(){
                    base64 = image2Base64(img);
                    content.append($("<img src='"+base64+"' width='100%'/>")); //装转为Base64的图片添加到窗口中
                }
                //页面层
                layer.open({
                    type: 1,
                    skin: false, //加上边框
                    title: "毕业证第二页",
                    area: ['400px', 'AUTO'], //宽高
                    content: content,  //
                    btn:['打印',"取消"],
                    yes:function(){
                        content.jqprint();
                        layer.load(1, {
                            shade: 0.5,
                            time: 3*1000,
                        });
                    }
                });
            });
            //打印第三页
            $("#datas").on("click",'.print_three',function(){
                //请求数据，生成图片
                var content = $("#print_first")
                var _this = $(this)
                var _time = Date.parse( new Date() ).toString();//获取到毫秒的时间戳，精确到毫秒
                _time = _time.substr(0,10);//精确到秒
                content.empty();

                var base64="";
                var img = new Image();
                img.src= "<?php echo url('Graduates/three_page'); ?>?id="+_this.data('id');
                img.onload=function(){
                    base64 = image2Base64(img);
                    content.append($("<img src='"+base64+"' width='100%'/>")); //装转为Base64的图片添加到窗口中
                }
                //页面层
                layer.open({
                    type: 1,
                    skin: false, //加上边框
                    title: "毕业证第三页",
                    area: ['400px', 'AUTO'], //宽高
                    content: content,  //
                    btn:['打印',"取消"],
                    yes:function(){
                        content.jqprint();
                        layer.load(1, {
                            shade: 0.5,
                            time: 3*1000,
                        });
                        setTimeout(()=> {
                            var advice_print_msg = layer.msg('毕业证三页全部打印成功后请在此处已确认【' + _this.data("name") + '】同学的毕业证以打印完毕!', {
                                time: 200000, //20s后自动关闭
                                shade: 0.8,
                                btn: ['完成', '重新打印'],
                                btn1: function () {
                                    $.post("<?php echo url('Graduates/print_time'); ?>", {
                                        id: _this.data('id'),
                                        print_time: _time,
                                    }, function (data) {
                                        layer.closeAll();
                                        layer.msg(data.msg, {time: 2000, shade: 0.5}, function () {
                                            $("#search").click();
                                        });
                                    });
                                },
                                btn2: function () {
                                    layer.close(advice_print_msg)
                                }
                              })
                        },4000);

                    }
                });
            });
            //上传文件
            upload.render({
                elem: '#test3'
                ,url: "<?php echo url('Graduates/import'); ?>" //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,field:'inputExcelclass'
                ,done: function(res){
                    layer.close(loading)
                    layer.msg(res.msg,{time:2000,shade:0.5},function(){
                        $("#search").click();
                    });
                }
                ,before:function(){
                    loading = layer.load(2,{
                        time:200000,
                        shade:0.5
                    })

                }
            });
            //清空数据
            $("#delall").on("click",function(){
                advice_print_msg = layer.msg('本次删除为永久删除，请确保数据已经备份，任要删除吗？', {
                    time: 200000, //20s后自动关闭
                    shade: 0.8,
                    btn: ['删除', '取消'],
                    btn1: function () {
                        $.post("<?php echo url('Graduates/delall'); ?>", {}, function (data) {
                            layer.closeAll();
                            layer.msg(data.msg, {time: 2000, shade: 0.5}, function () {
                                $("#search").click();
                            });
                        });
                    },
                    btn2: function () {
                        layer.close(advice_print_msg)
                    }
                })

            })

        });
        //把图片转为Base64
        function image2Base64(img) {
            var canvas = document.createElement("canvas");
            canvas.width = img.width;
            canvas.height = img.height;
            var ctx = canvas.getContext("2d");
            ctx.drawImage(img, 0, 0, img.width, img.height);
            var dataURL = canvas.toDataURL("image/jpeg");
            return dataURL;
        }

    </script>

    
    

</body>

</html>
